package com.manner.groupon.controller.user;

import com.manner.groupon.common.BaseResponse;
import com.manner.groupon.common.PageResult;
import com.manner.groupon.common.ResultUtils;
import com.manner.groupon.model.dto.order.AdminOrderDTO;
import com.manner.groupon.model.dto.search.OrderSearch;
import com.manner.groupon.model.vo.*;
import com.manner.groupon.service.groupon.GrouponOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/coupon-order")
@RequiredArgsConstructor
public class GrouponOrderController {

    private final GrouponOrderService grouponOrderService;

    @GetMapping
    public BaseResponse<PageResult<CouponOrderVo>> search(OrderSearch search) {
        return grouponOrderService.search(search);
    }

    @GetMapping("/phone/{phone}")
    public BaseResponse<PageResult<CouponOrderVo>> list(String orderNo, @PathVariable String phone, int current, int pageSize, int status, String userPhone) {
        return grouponOrderService.query_list(orderNo, phone, current, pageSize, status, userPhone);
    }

    @GetMapping("/{no}")
    public BaseResponse<OrderDetailVo> queryByNo(@PathVariable String no) {
        return grouponOrderService.query_no(no);
    }

    @GetMapping("/admin")
    public BaseResponse<PageResult<AdminOrderVO>> search(AdminOrderDTO adminOrderDTO) {
        return grouponOrderService.query_search(adminOrderDTO);
    }
}
